class Time_Tools:
    """
    获取时间工具类
    """

    @staticmethod
    def get_file_mouth(file_name, start_area_code="5105.") -> int:
        """
        获取文件导出月份
        :param file_name: 文件名称
        :param start_area_code: 区域名称 eg 泸州市 5105.
        :return: 导出月份
        """
        file_name = file_name[file_name.find(start_area_code) + 5:]
        file_name = file_name[0:file_name.find(".")]
        mouth = int(file_name[4:len(file_name)])
        if not (mouth >= 1 or mouth <= 12):
            raise ValueError("文件月份有误，请检查")
        return mouth

    @staticmethod
    def get_file_year_mouth(file_name, start_area_code="5105.") -> int:
        # ./res/访户记录/辅导员监控.5105.20247.20240801.134654.csv
        file_name = file_name[file_name.find(start_area_code) + 5:]
        file_name = file_name[0:file_name.find(".")]
        year = file_name[:4]
        month = file_name[4:]
        if int(month) < 10:
            month = "0" + str(month)

        return int(year+month)
